package main

import (
	"fmt"
	"strconv"
	"strings"
)

func Solve(target int,maxNum int)int{
	ans:=0
	flag:=1
	for i:=0;i<maxNum;i++{
		flag*=2
		if flag>target{
			flag/=2
			break
		}else{
			ans++
		}
	}
	return target-flag+ans
}
func getAns(nums []int,left int,right int)int  {
	ans:=0
	for i:=left;i<right;i++{
		ans+=nums[i]
	}
	return ans
}
func main() {
	var temp string
	fmt.Scan(&temp)
	strsum:=strings.Split(temp,",")
	nums:=make([]int,2)
	nums[0],_=strconv.Atoi(strsum[0])
	nums[1],_=strconv.Atoi(strsum[1])
	fmt.Println(Solve(nums[0],nums[1]))
}
func min(a,b int)int{
	if a>b{
		return b
	}
	return a
}
func max(a,b int)int{
	if a>b{
		return a
	}
	return b
}


